// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: BG Swapper
// Script Author: Christian Whitehead/Simon Thomley/Tails LP
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------



event ObjectDraw
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		temp0 = object.Value0
		flipSign(temp0)
		temp1 = object.Value1
		flipSign(temp1)
		BoxCollisionTest(C_TOUCH, object.entityPos, temp0, temp1, object.Value0, object.Value1, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		if checkResult == 1
			switch object.propertyValue
			case 1
				Stage[0].ActiveLayer= 1
				break
			case 2
				Stage[0].ActiveLayer= 2
				break
			end switch
		endif
	next
endevent


event ObjectStartup
	temp0=16384
	temp1=0
	ArrayPos0=32
	while ArrayPos0<1056
		if Object[ArrayPos0].Type==TypeName[BG Swapper]
			if Object[ArrayPos0].iXPos<temp0
				temp0=Object[ArrayPos0].iXPos
			endif
			if Object[ArrayPos0].iXPos>temp1
				temp1=Object[ArrayPos0].iXPos
			endif
		endif
		ArrayPos0++
	loop
endevent

event RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endevent
